// pages/exam/exam.js
const App = getApp()
const {
  get,
  post
} = App.require('request/index')
;
import Dialog from '@vant/weapp/dialog/dialog';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    countdown: '', //倒计时
    totleList: [],
    index: 0,
    answer: {},
    disabled: false,
    navHeight:App.globalData.navHeight,
    subObj: {},
    time: null,
    timeout:"",
    clear:"",
    id:null,
    check:false,
    prolist: wx.getStorageSync('prolist') == '' ? wx.getStorageSync('prolist') : JSON.parse(wx.getStorageSync('prolist')),
  },
   
 


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

    let opt = JSON.parse(options.data)
  
    let str = ""
     opt.answerList.map(item=>{
       if(item.analysis){
        str=item.analysis
       }
     })

    if (opt) {
      this.setData({
        subObj: {...opt,str:str},
        
      })
      // this.countdown()
      // this.getpaperqudetail();
    }

  },
  submt(){
    this.setData({
      check:true
    })
  },
  // 强制交卷

  change(e) {
    this.setData({
      subObj: {
        ...e.detail
      }
    })
  },
 
  clock(e){
    
    this.setData({
      id:e.currentTarget.dataset.id
    })
  },
  


  
  // 下一题
  lower(e) {
   this.setData({
     check:false
   })
    let {
      prolist
    } = this.data
    console.log(e);
    let {nextquid,repoid} = e.currentTarget.dataset
 if(nextquid){
  post('/app/exam/question/trainingAnswer',{repoId:repoid,quId:nextquid,memberId:prolist.userid}).then(res => {
    let str = ""
    res.data.answerList.map(item=>{
      if(item.analysis){
       str=item.analysis
      }
    })
    
    this.setData({
      subObj:{...res.data,str:str} 
    })
 
  })
 }else{
  wx.showToast({
    title: '没训练题了，亲！',
    icon: 'success',
    duration: 2000
  })
 }
   
    

    
  },
  // 上一题
  upper() {
    this.submine()
    let {
      index,
      totleList
    } = this.data
    index--
    this.setData({
      index: index--,
      disabled: false,
    })
    this.getpaperqudetail();
  },

  getpaperqudetail() {
    wx.showLoading({
      title: '加载中',
    })
    let {
      totleList,
      index
    } = this.data

   
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})